<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="/static/jquery-1.11.3.min.js"></script>
    <script>
        $(function () {
            $('#username').blur(function () {
                console.log(this);
                var u = $(this).val();
                console.log(u);
                $.get('/existName.do','username='+u,function (data) {
                    console.log(data);
                    $('#result').html(data.msg);
                    if(data.success){
                        $('#result').css('color','green');
                    }else {
                        $('#result').css('color','red');
                    }
                })
            })
        })
    </script>
</head>

<body>
    <input type="text" id="username" placeholder="用户名">
    <span id="result"></span>
</body>
</html>